package com.top.mall.main.mine.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.top.mall.R
import com.top.mall.entity.AreaList


class Area1Adapter : BaseQuickAdapter<AreaList, BaseViewHolder>(R.layout.item_area_list) {
    var selectPosition = -1
        set(value) {
            if (field != value) {
                field = value
                notifyDataSetChanged()
            }
        }

    override fun convert(holder: BaseViewHolder, item: AreaList) {
        holder.getView<TextView>(R.id.tvAreaListName).apply {
            if (selectPosition == holder.layoutPosition) {
                setBackgroundResource(R.color.FF_F5F5F5)
            } else {
                setBackgroundResource(R.color.transparent)
            }
        }.text = item.name

    }
}

class Area2Adapter : BaseQuickAdapter<AreaList, BaseViewHolder>(R.layout.item_area_list) {
    var selectPosition = -1
        set(value) {
            if (field != value) {
                field = value
                notifyDataSetChanged()
            }
        }

    override fun convert(holder: BaseViewHolder, item: AreaList) {
        holder.getView<TextView>(R.id.tvAreaListName).apply {
            if (selectPosition == holder.layoutPosition) {
                setBackgroundResource(R.color.FF_F5F5F5)
            } else {
                setBackgroundResource(R.color.transparent)
            }
        }.text = item.name
    }
}

class Area3Adapter : BaseQuickAdapter<AreaList, BaseViewHolder>(R.layout.item_area_list) {
    var selectPosition = -1
        set(value) {
            if (field != value) {
                field = value
                notifyDataSetChanged()
            }
        }

    override fun convert(holder: BaseViewHolder, item: AreaList) {
        holder.getView<TextView>(R.id.tvAreaListName).apply {
            if (selectPosition == holder.layoutPosition) {
                setBackgroundResource(R.color.FF_F5F5F5)
            } else {
                setBackgroundResource(R.color.transparent)
            }
        }.text = item.name
    }
}